package com.acwing.partition13;

import java.io.*;
import java.util.Arrays;

/**
 * @author `RKC`
 * @date 2022/3/4 9:49
 */
public class AC1239乘积最大 {

    private static final int N = 100010, MOD = 1000000009;
    private static int[] nums = new int[N];
    private static int n, k;

    private static final BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    private static final BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));

    public static void main(String[] args) throws IOException {
        String[] ss = reader.readLine().split(" ");
        n = Integer.parseInt(ss[0]);
        k = Integer.parseInt(ss[1]);
        for (int i = 0; i < n; i++) nums[i] = Integer.parseInt(reader.readLine());
        Arrays.sort(nums, 0, n);
        int ans = 1, sign = 1, l = 0, r = n - 1;
        //如果要选择的数是奇数个的话，选择最大的一个，转换为选择偶数个的情况
        if ((k & 1) == 1) {
            ans = nums[r--];
            k--;
            if (ans < 0) sign = -1;
        }
        while (k > 0) {
            long x = (long) nums[l] * nums[l + 1], y = (long) nums[r] * nums[r - 1];
            if (x * sign > y * sign) {
                ans = (int) (x % MOD * ans % MOD);
                l += 2;
            } else {
                ans = (int) (y % MOD * ans % MOD);
                r -= 2;
            }
            k -= 2;
        }
        writer.write(ans + "\n");
        writer.flush();
    }
}
